package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.domain.City;
import com.itheima.domain.User;
import com.itheima.mapper.UserMapper;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

//    查询城市信息
    @Override
    public List<City> findAll() {

        return userMapper.findAll();
    }

    //查询单个城市
    @Override
    public City findByCId(Integer cid) {
        return userMapper.findByCId(cid);
    }

    @Override
    public void add(User user) {
        String uuid = UUID.randomUUID().toString().replace("-", "");
        System.out.println(uuid);
//        if (true) return;
        user.setId(uuid);
        userMapper.add(user);
    }

    @Override
    public User findOne(String email, String password) {

        return userMapper.findOne(email,password);
    }


    @Override
    public List<User> findList(Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum,pageSize);

        return  userMapper.findList();
    }


}
